﻿using B.R.RabbitRoot.Domain;
using B.R.RabbitRoot.Domain.animal_husbandry;
using B.R.RabbitRoot.Domain.processing_plant;
using B.R.RabbitRoot.Domain.RBAS;
using B.R.RabbitRoot.Domain.slaughter;
using Microsoft.EntityFrameworkCore;

namespace B.R.RabbitRoot.Infrastructure
{
    /// <summary>
    /// 上下文
    /// </summary>
    public class RabbitDbcontext : DbContext
    {
        /// <summary>
        /// 构造函数 :base 调用的父类构造函数
        /// </summary>
        /// <param name="options"></param>
        public RabbitDbcontext(DbContextOptions<RabbitDbcontext> options) : base(options)
        {
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //给实体添加表明
            modelBuilder.Entity<Classpractice>().ToTable("Classpractices");
            //给实体添加主键
            modelBuilder.Entity<Classpractice>().HasKey(s=>s.ClasspracticeId);
            //给实体添加字段长度
            modelBuilder.Entity<Classpractice>().Property(s=>s.ClasspracticeName).HasMaxLength(50);

            modelBuilder.Entity<Role>().ToTable("Roles");
            modelBuilder.Entity<Role>().HasKey(s=>s.RoleId);
            modelBuilder.Entity<Role>().Property(s => s.RoleId).ValueGeneratedNever();
            modelBuilder.Entity<Role>().Property(s=>s.RoleName).HasMaxLength(50);

            modelBuilder.Entity<User_Role>().ToTable("User_Roles");
            modelBuilder.Entity<User_Role>().HasKey(s => s.UserRoleId);
            modelBuilder.Entity<User_Role>().Property(s => s.AccountId).HasMaxLength(50);
            modelBuilder.Entity<User_Role>().Property(s => s.RoleId).HasMaxLength(50);

            modelBuilder.Entity<Menu>().ToTable("Menus");
            modelBuilder.Entity<Menu>().HasKey(s => s.MenuId);
            modelBuilder.Entity<Menu>().Property(s => s.MenuName).HasMaxLength(50);
            modelBuilder.Entity<Menu>().Property(s => s.MuenuUrl).HasMaxLength(200);
            modelBuilder.Entity<Menu>().Property(s => s.PerentId).HasMaxLength(50);
            modelBuilder.Entity<Menu>().Property(s => s.MenuId).ValueGeneratedNever();

            modelBuilder.Entity<Role_Menu>().ToTable("Role_Menus");
            modelBuilder.Entity<Role_Menu>().HasKey(s => s.RoleNameId);
            modelBuilder.Entity<Role_Menu>().Property(s => s.RoleId);
            modelBuilder.Entity<Role_Menu>().Property(s => s.MenuId);
        }
        /// <summary>
        /// 角色表
        /// </summary>
        public DbSet<Role> Roles  { get; set; }
        /// <summary>
        /// 用户角色表
        /// </summary>
        public DbSet<User_Role> User_Roles  { get; set; }
        /// <summary>
        /// 菜单表
        /// </summary>
        public DbSet<Menu> Menus  { get; set; }
        /// <summary>
        /// 角色菜单表
        /// </summary>
        public DbSet<Role_Menu> Role_Menus  { get; set; }
        /// <summary>
        /// redis测试
        /// </summary>
        public DbSet<Classpractice> Classpractices { get; set; }
        /// <summary>
        /// 溯源信息表
        /// </summary>
        public DbSet<SourceInfo> SourceInfos { get; set; }
        /// <summary>
        /// 图片表
        /// </summary>
        public DbSet<ImageTable> ImageTables { get; set; }
        /// <summary>
        /// 屠宰信息
        /// </summary>
        public DbSet<SlaughterInfo> SlaughterInfos  { get; set; }
        /// <summary>
        /// 公司地址
        /// </summary>
        public DbSet<companyaddress> Companyaddresses { get; set; }
        /// <summary>
        /// 屠宰企业信息
        /// </summary>
        public DbSet<butcherCompany> ButcherCompanies { get; set; }
        /// <summary>
        /// 深加工信息
        /// </summary>
        public DbSet<DeepProcessingTeamInfo> DeepProcessingTeamInfos { get; set; }
        /// <summary>
        /// 深加工企业信息
        /// </summary>
        public DbSet<ProcessingEnterpriseInfo> ProcessingEnterpriseInfos { get; set; }
        /// <summary>
        /// 供应商信息
        /// </summary>
        public DbSet<SupplierInfo> SupplierInfos { get; set; }
        /// <summary>
        /// 保健信息
        /// </summary>
        public DbSet<HealthCareInfo> HealthCareInfos { get; set; }
        /// <summary>
        /// 养殖信息
        /// </summary>
        public DbSet<FarmingDetails> FarmingDetails { get; set; }
        /// <summary>
        /// 养殖企业信息
        /// </summary>
        public DbSet<FarmInfo> FarmInfos { get; set; }
        /// <summary>
        /// 登陆表
        /// </summary>
        public DbSet<Account> Accounts  { get; set; }
        /// <summary>
        /// 商品名称
        /// </summary>
        public DbSet<product> products  { get; set; }
    }
}
